{extend name="layout" /}onepay
{block name="content"}
<div class="content-wrapper">
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">创建数据库</h4>
                    <form class="layui-form forms-sample">
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">数据库类型</label>
                            <div class="col-sm-9">
                                <select name="db[type]" required lay-verify="required" class="form-control">
                                    <option value="">请选择数据库数据库类型</option>
                                    <option value="mysql">mysql</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">数据库地址</label>
                            <div class="col-sm-9">
                                <input type="text" name="db[hostname]" value="127.0.0.1" required lay-verify="required"  class="form-control" placeholder="数据库地址">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">端口号</label>
                            <div class="col-sm-9">
                                <input type="text" name="db[hostport]" value="3306" required lay-verify="required"  class="form-control" placeholder="端口号">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">数据库名</label>
                            <div class="col-sm-9">
                                <input type="text" name="db[database]" value="Onepay" required lay-verify="required"  class="form-control" placeholder="数据库名">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">用户名</label>
                            <div class="col-sm-9">
                                <input type="text" name="db[username]" value="root" required lay-verify="required"  class="form-control" placeholder="用户名">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">密码</label>
                            <div class="col-sm-9">
                                <input type="password" name="db[password]" value="123456" required lay-verify="required"  class="form-control" placeholder="密码">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label">表前缀</label>
                            <div class="col-sm-9">
                                <input type="text" name="db[prefix]" value="cm_" required lay-verify="required"  class="form-control" placeholder="表前缀">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label  class="col-sm-3 col-form-label"></label>
                            <div class="col-sm-9">
                                <a class="btn btn-outline-primary btn-large" href="{:url('install/Index/step1')}">上一步</a>
                                <button type="button" class="btn btn-primary btn-submit-install btn-fw" lay-submit lay-filter="app-install-submit">下一步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagejs"}
<script>
    layui.use(['form'], function(){
        let $ = layui.$
            ,form = layui.form;
        //监听提交
        form.on('submit(app-install-submit)', function(data){
            let field = data.field;
            console.log(field)
            //提交安装
            $.ajax({
                url:'{:url(\'install/Index/step2\')}',
                method:"POST",
                data:field,
                success:function (res) {
                    showToast(res);
                    if (res.code == 1){
                        setTimeout(function () {
                            location.href = '/'
                        },1500)
                    }
                }
            });
        });
    });
</script>
{/block}